package com.sxm.yiwei.adapters.pinche;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.squareup.picasso.Picasso;
import com.sxm.yiwei.R;
import com.sxm.yiwei.beans.pinche.Order;
import com.sxm.yiwei.constant.Common;
import com.sxm.yiwei.constant.Constant;
import com.sxm.yiwei.pinche.ReleaseActivity;
import com.sxm.yiwei.tools.BookPayActivity;
import com.sxm.yiwei.tools.CallPhone;
import com.sxm.yiwei.tools.CircleTransform;
import com.sxm.yiwei.views.CircleImage;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/10/28.
 */

public class PincheOrderListAdapter extends BaseAdapter {
    private final LayoutInflater inflater;
    private Context context;
    private ArrayList<Order> list;
    private int identity;
    private int order_type;
    private int go_type;
    private OnOrderHandleListener onOrderHandleListener;
    public PincheOrderListAdapter(Context context,ArrayList<Order> list,int identity,int order_type,int go_type) {
        this.context=context;
        this.list=list;
        inflater = LayoutInflater.from(context);
        this.identity=identity;
        this.order_type=order_type;
        this.go_type=go_type;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        final Order order = list.get(i);
        if (identity== Constant.PASSENGER&&go_type!=Constant.LONG_HURRY){
           switch (order_type){
               case Constant.WAIT_PAY:
                   ViewHolder holder=null;
                   if (view==null){
                       view=inflater.inflate(R.layout.passenger_wait_pay_long_item,null);
                       holder=new ViewHolder();
                       holder.title_info=(TextView)view.findViewById(R.id.tv_title_info);
                       holder.title_money=(TextView)view.findViewById(R.id.tv_title_money);
                       holder.icon=(CircleImage) view.findViewById(R.id.iv_icon);
                       holder.nickname=(TextView)view.findViewById(R.id.tv_nickname);
                       holder.time=(TextView)view.findViewById(R.id.tv_recent_come);
                       holder.words=(TextView)view.findViewById(R.id.tv_words);
                       holder.start_pos=(TextView)view.findViewById(R.id.tv_start_pos);
                       holder.end_pos=(TextView)view.findViewById(R.id.tv_end_pos);
                       holder.seats=(TextView)view.findViewById(R.id.tv_transfer_fee);
                       holder.total_price=(TextView)view.findViewById(R.id.tv_total_price);
                       holder.departTime=(TextView)view.findViewById(R.id.tv_depart_time);
                       holder.btnBuy=(TextView)view.findViewById(R.id.btn_buy);
                       holder.line=(View)view.findViewById(R.id.title_line);
                       holder.tv_words_release=(TextView)view.findViewById(R.id.tv_words_release);
                       holder.ll_buy=(LinearLayout)view.findViewById(R.id.ll_buy);
                       holder.ll_bottom_release=(LinearLayout)view.findViewById(R.id.ll_bottom_release);
                       holder.ll_bottom_buy=(LinearLayout)view.findViewById(R.id.ll_bottom_buy);
                       holder.release_again=(TextView)view.findViewById(R.id.btn_release_again);
                       view.setTag(holder);
                   }else {
                       holder= (ViewHolder) view.getTag();
                   }

                   if (order.getForm_way()==Constant.RELEASE){//信息未发布
                       holder.line.setVisibility(View.GONE);
                       holder.tv_words_release.setVisibility(View.VISIBLE);
                       holder.ll_buy.setVisibility(View.GONE);
                       holder.ll_bottom_buy.setVisibility(View.GONE);
                       holder.ll_bottom_release.setVisibility(View.VISIBLE);
                       if (TextUtils.isEmpty(order.getWords())){
                           holder.tv_words_release.setText("我的留言：车主很懒，没有留言");
                       }else {
                           holder.tv_words_release.setText("我的留言："+order.getWords());
                       }
                       if (order.getIs_timeout()==Constant.YES){
                           holder.title_info.setText("已超时，需支付");
                           holder.release_again.setText("重新发布");
                       }else {
                           holder.title_info.setText("信息未发布，票价");
                           holder.release_again.setText("立即发布");
                       }

                   }else if (order.getForm_way()==Constant.BUY){//未购票
                        holder.line.setVisibility(View.VISIBLE);
                       holder.tv_words_release.setVisibility(View.GONE);
                       holder.ll_buy.setVisibility(View.VISIBLE);
                       Picasso.with(context).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(holder.icon);
                       if(TextUtils.isEmpty(order.getNickname())){
                           holder.nickname.setText("暂无昵称");
                       }else {
                           holder.nickname.setText(order.getNickname());
                       }
                       if (order.getVehicle_type()==Constant.BUS){
                           holder.nickname.setCompoundDrawablesWithIntrinsicBounds(null,null,context.getResources().getDrawable(R.mipmap.bus),null);
                       }else {
                           holder.nickname.setCompoundDrawablesWithIntrinsicBounds(null,null,context.getResources().getDrawable(R.mipmap.car1),null);
                       }
                       if (TextUtils.isEmpty(order.getWords())){
                           holder.words.setText("车主留言：车主很懒，没有留言");
                       }else {
                           holder.words.setText("车主留言："+order.getWords());
                       }
                       holder.time.setText(order.getStart_time());
                       if (order.getIs_timeout()==Constant.YES){
                           holder.title_info.setText("已超时，需支付");
                           holder.ll_bottom_release.setVisibility(View.GONE);
                           holder.ll_bottom_buy.setVisibility(View.GONE);
                       }else {
                           holder.title_info.setText("车票未购买成功，票价");
                           holder.ll_bottom_buy.setVisibility(View.VISIBLE);
                           holder.ll_bottom_release.setVisibility(View.GONE);
                       }
                   }


                   holder.release_again.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View view) {
                           //Toast.makeText(context,"重新发布 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                            if (order.getIs_timeout()==Constant.YES){
                                Intent intent = new Intent(context, ReleaseActivity.class);
                                intent.putExtra("identity",identity);
                                context.startActivity(intent);

                            }else {
                                //掉用生成订单接口，跳转支付页面
                                if (!TextUtils.isEmpty(order.getOrder_id())){
                                    Intent intent = new Intent(context, BookPayActivity.class);
                                    intent.putExtra("orderCode",order.getOrder_id());
                                    intent.putExtra("amount", order.getTotal_money()+"");
                                    intent.putExtra("from", Constant.PASSENGER_PUBLISH_PAY);
                                    intent.putExtra("id",order.getService_id());
                                    intent.putExtra("alipay",Common.PASSENGER_PUBLISH_ALIPAY);
                                    intent.putExtra("yivipay",Common.PASSENGER_PUBLISH_RESTPAY);
                                    context.startActivity(intent);
                                }else {
                                    Toast.makeText(context,"order_id为空",Toast.LENGTH_SHORT).show();
                                }

                            }
                       }
                   });
                   holder.btnBuy.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View view) {
                           //Toast.makeText(context,"购票 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                           //先调用生成订单接口，在跳转支付页面
                           if (!TextUtils.isEmpty(order.getOrder_id())){
                               Intent intent = new Intent(context, BookPayActivity.class);
                               intent.putExtra("orderCode",order.getOrder_id());
                               intent.putExtra("amount", order.getTotal_money()+"");
                               intent.putExtra("from", Constant.PASSENGER_ROB_PAY);
                               intent.putExtra("id",order.getService_id());
                               intent.putExtra("alipay",Common.PASSENGER_SEARCH_ALIPAY);
                               intent.putExtra("yivipay",Common.PASSENGER_SEARCH_RESTPAY);
                               context.startActivity(intent);
                           }else {
                               Toast.makeText(context,"order_id为空",Toast.LENGTH_SHORT).show();
                           }


                       }
                   });
                   //公共
                   holder.start_pos.setText(order.getStart_place());
                   holder.end_pos.setText(order.getEnd_place());
                   holder.seats.setText(order.getSeats()+"个");
                   holder.total_price.setText(order.getTotal_money()+"元");
                   holder.departTime.setText(order.getDepart_time());
                   holder.title_money.setText(order.getSingle_money()+"元");

                   break;
               case Constant.WAIT_TAKE:
                   ViewHolderWaitTake holder1=null;
                   if (view==null){
                       view=inflater.inflate(R.layout.passenger_wait_take_long_item,null);
                       holder1=new ViewHolderWaitTake();
                       holder1.title_info=(TextView)view.findViewById(R.id.tv_title_info);
                       holder1.words=(TextView)view.findViewById(R.id.tv_words);
                       holder1.start_pos=(TextView)view.findViewById(R.id.tv_start_pos);
                       holder1.end_pos=(TextView)view.findViewById(R.id.tv_end_pos);
                       holder1.seats=(TextView)view.findViewById(R.id.tv_transfer_fee);
                       holder1.total_price=(TextView)view.findViewById(R.id.tv_total_price);
                       holder1.departTime=(TextView)view.findViewById(R.id.tv_depart_time);
                       holder1.btnCancel=(TextView)view.findViewById(R.id.btn_phone);
                       holder1.btnReleaseAgain=(TextView)view.findViewById(R.id.btn_release_again);
                       view.setTag(holder1);
                   }else {
                       holder1= (ViewHolderWaitTake) view.getTag();
                   }

                   if (order.getIs_timeout()==Constant.YES){
                       holder1.title_info.setText("已超时");
                       holder1.btnReleaseAgain.setVisibility(View.VISIBLE);
                   }else{
                       holder1.title_info.setText("待车主接单，请耐心等待");
                       holder1.btnReleaseAgain.setVisibility(View.GONE);
                   }
                   holder1.words.setText("我的留言："+order.getWords());
                   holder1.start_pos.setText(order.getStart_place());
                   holder1.end_pos.setText(order.getEnd_place());
                   holder1.seats.setText(order.getSeats()+"个");
                   holder1.total_price.setText(order.getTotal_money()+"元");
                   holder1.departTime.setText(order.getDepart_time());
                   holder1.btnReleaseAgain.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View view) {
                           //Toast.makeText(context,"重新发布 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                           Intent intent = new Intent(context, ReleaseActivity.class);
                           intent.putExtra("identity",identity);
                           context.startActivity(intent);
                           // TODO: 2017/11/14 费用是否退回
                       }
                   });
                   holder1.btnCancel.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View view) {
                           //Toast.makeText(context,"取消订单 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                           //费用要返还
                           onOrderHandleListener.onCancelOrder(order.getForm_way()+"",order_type+"",order.getOrder_id()+"",i,Constant.CANCEL_ORDER);
                       }
                   });
                   break;
               case Constant.WAIT_SURVICE:
               case Constant.IN_SURVICE:
               case Constant.WAIT_FINISH:
               case Constant.FINISHED:
                   ViewHolderWaitSurvice holder2=null;
                   if (view==null){
                       view=inflater.inflate(R.layout.passenger_wait_survice_long_item,null);
                       holder2=new ViewHolderWaitSurvice();
                       holder2.icon=(CircleImage) view.findViewById(R.id.iv_icon);
                       holder2.nickname=(TextView)view.findViewById(R.id.tv_nickname);
                       holder2.recent_come =(TextView)view.findViewById(R.id.tv_recent_come);
                       holder2.words=(TextView)view.findViewById(R.id.tv_words);
                       holder2.start_pos=(TextView)view.findViewById(R.id.tv_start_pos);
                       holder2.end_pos=(TextView)view.findViewById(R.id.tv_end_pos);
                       holder2.seats=(TextView)view.findViewById(R.id.tv_transfer_fee);
                       holder2.total_price=(TextView)view.findViewById(R.id.tv_total_price);
                       holder2.loss=(TextView)view.findViewById(R.id.tv_loss_money);
                       holder2.departTime=(TextView)view.findViewById(R.id.tv_depart_time);
                       holder2.btnPhone =(TextView)view.findViewById(R.id.btn_phone);
                       holder2.btnWei=(TextView)view.findViewById(R.id.btn_wei);
                       holder2.text=(TextView)view.findViewById(R.id.text);

                       holder2.line=(View)view.findViewById(R.id.line);
                       holder2.title_info=(TextView)view.findViewById(R.id.tv_title_info);

                       holder2.ll_loss=(LinearLayout)view.findViewById(R.id.ll_loss);
                       holder2.btnInCar=(TextView)view.findViewById(R.id.btn_in_car);
                       view.setTag(holder2);
                   }else {
                       holder2= (ViewHolderWaitSurvice) view.getTag();
                   }
                   Picasso.with(context).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(holder2.icon);
                   if (TextUtils.isEmpty(order.getNickname())){
                       holder2.nickname.setText("暂无昵称");

                   }else {
                       holder2.nickname.setText(order.getNickname());

                   }
                   holder2.recent_come.setText("[24h前来过]");// TODO: 2017/11/14 喂一下
                   if (order.getWho_created()==Constant.HOST){
                       holder2.words.setText("我的留言："+order.getWords());
                       holder2.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chengke),null,null,null);
                       holder2.text.setText("座位需求");
                   }else {
                       holder2.words.setText("车主留言："+order.getWords());
                       holder2.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chezhu),null,null,null);
                       holder2.text.setText("提供座位");

                   }

                   holder2.start_pos.setText(order.getStart_place());
                   holder2.end_pos.setText(order.getEnd_place());
                   holder2.seats.setText(order.getSeats()+"个");
                   holder2.total_price.setText(order.getTotal_money()+"元");
                   holder2.departTime.setText(order.getDepart_time());
                   holder2.loss.setText(order.getLoss_money()+"元");
                   if (order_type==Constant.WAIT_SURVICE){
                       holder2.ll_loss.setVisibility(View.VISIBLE);
                       holder2.btnInCar.setVisibility(View.GONE);
                       holder2.line.setVisibility(View.GONE);
                       holder2.title_info.setVisibility(View.GONE);
                   }else if (order_type==Constant.IN_SURVICE){
                       holder2.ll_loss.setVisibility(View.GONE);
                       holder2.btnInCar.setVisibility(View.VISIBLE);
                       holder2.line.setVisibility(View.GONE);
                       holder2.title_info.setVisibility(View.GONE);
                       if (order.getIs_in_car()==Constant.YES){
                           holder2.btnInCar.setText("行程完结");

                       }else if (order.getIs_in_car()==Constant.NO){
                           holder2.btnInCar.setText("我已上车");

                       }
                   }else if (order_type==Constant.WAIT_FINISH){
                        holder2.ll_loss.setVisibility(View.GONE);
                       if (order.getIs_finished()==Constant.HOST_FINISHED_PASSENGER_NO){
                           holder2.btnInCar.setVisibility(View.VISIBLE);
                           holder2.btnInCar.setText("行程完结");
                           holder2.line.setVisibility(View.GONE);
                           holder2.title_info.setVisibility(View.GONE);
                       }else if (order.getIs_finished()==Constant.PASSENGER_FINISHED_HOST_NO){
                           holder2.btnInCar.setVisibility(View.GONE);
                           holder2.line.setVisibility(View.VISIBLE);
                           holder2.title_info.setVisibility(View.VISIBLE);
                           holder2.title_info.setText("等待对方完结");
                       }

                   }else if (order_type==Constant.FINISHED){
                        holder2.ll_loss.setVisibility(View.GONE);
                       holder2.btnInCar.setVisibility(View.VISIBLE);
                       holder2.btnInCar.setText("再次发布");
                       holder2.line.setVisibility(View.GONE);
                       holder2.title_info.setVisibility(View.GONE);
                   }

                   holder2.btnWei.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View view) {
                           //Toast.makeText(context,"喂一下 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                           Toast.makeText(context,"暂未开放",Toast.LENGTH_LONG).show();


                       }
                   });
                   holder2.btnInCar.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View view) {
                           if (order_type==Constant.FINISHED){
                              // Toast.makeText(context,"再次发布 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                               Intent intent = new Intent(context, ReleaseActivity.class);
                               intent.putExtra("identity",identity);
                               context.startActivity(intent);

                           }else if (order_type==Constant.WAIT_FINISH){
                               //Toast.makeText(context,"行程完结 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                onOrderHandleListener.onRouteFinish(identity+"",order.getOrder_id(),i,Constant.ROUTE_FINISHED);
                           }else if(order_type==Constant.IN_SURVICE){
                               if (order.getIs_in_car()==Constant.YES){
                                   //Toast.makeText(context,"行程完结 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                   onOrderHandleListener.onRouteFinish(identity+"",order.getOrder_id(),i,Constant.ROUTE_FINISHED);

                               }else if (order.getIs_in_car()==Constant.NO){
                                   //Toast.makeText(context,"我已上车 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                   onOrderHandleListener.onAlreadyInCarClick(order.getOrder_id(),i,Constant.ALREADY_IN_CAR);

                               }
                           }

                       }
                   });
                   holder2.btnPhone.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View view) {
                           if (!TextUtils.isEmpty(order.getPhone())){
                               CallPhone.callPhone(context,order.getPhone());
                           }else {
                               Toast.makeText(context,"电话为空",Toast.LENGTH_LONG).show();
                           }
                       }
                   });
                   break;
               case Constant.LOSS:
                   ViewHolderLoss holder3=null;
                   if (view==null){
                       view=inflater.inflate(R.layout.passenger_loss_long_item,null);
                       holder3=new ViewHolderLoss();
                       holder3.icon=(CircleImage) view.findViewById(R.id.iv_icon);
                       holder3.nickname=(TextView)view.findViewById(R.id.tv_nickname);
                       holder3.words=(TextView)view.findViewById(R.id.tv_words);
                       holder3.start_pos=(TextView)view.findViewById(R.id.tv_start_pos);
                       holder3.end_pos=(TextView)view.findViewById(R.id.tv_end_pos);
                       holder3.seats=(TextView)view.findViewById(R.id.tv_transfer_fee);
                       holder3.total_price=(TextView)view.findViewById(R.id.tv_total_price);
                       holder3.loss=(TextView)view.findViewById(R.id.tv_loss_money);
                       holder3.departTime=(TextView)view.findViewById(R.id.tv_depart_time);
                       holder3.whoPay=(ImageView)view.findViewById(R.id.iv_whoPay);

                       holder3.title_info=(TextView)view.findViewById(R.id.tv_title_info);
                       holder3.text=(TextView)view.findViewById(R.id.tv_text);

                       view.setTag(holder3);
                   }else {
                       holder3= (ViewHolderLoss) view.getTag();
                   }
                   Picasso.with(context).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(holder3.icon);
                    holder3.nickname.setText(order.getNickname());
                   if (order.getVehicle_type()==Constant.BUS){
                       holder3.nickname.setCompoundDrawablesWithIntrinsicBounds(null,null,context.getResources().getDrawable(R.mipmap.bus),null);
                   }else {
                       holder3.nickname.setCompoundDrawablesWithIntrinsicBounds(null,null,context.getResources().getDrawable(R.mipmap.car1),null);
                   }
                   holder3.start_pos.setText(order.getStart_place());
                   holder3.end_pos.setText(order.getEnd_place());
                   holder3.seats.setText(order.getSeats()+"个");
                   holder3.total_price.setText(order.getTotal_money()+"元");
                   holder3.loss.setText(order.getLoss_money()+"元");
                   holder3.departTime.setText(order.getDepart_time());
                        if (order.getWhy_return().equals("退票")){
                            if (order.getWho_return()==Constant.ME){
                                if (order.getIs_return()==Constant.YES){
                                    holder3.title_info.setText("我赔付，爽约金将退还到对方账户");
                                    holder3.whoPay.setImageResource(R.mipmap.wotuipiao);
                                }else {
                                    holder3.title_info.setText("我爽约，但对方未缴纳爽约金，不用赔付");
                                    holder3.whoPay.setImageResource(R.mipmap.wotuipiao);
                                }

                            }else {
                                if (order.getIs_return()==Constant.YES){
                                    holder3.title_info.setText("对方赔付，爽约金稍后回到您的账户");
                                    holder3.whoPay.setImageResource(R.mipmap.duifangtuipiao);
                                }else {
                                    holder3.title_info.setText("对方爽约，但对方未缴纳爽约金，无赔付金额");
                                    holder3.whoPay.setImageResource(R.mipmap.duifangtuipiao);
                                }

                            }
                        }else if (order.getWhy_return().equals("改签")){
                            if (order.getWho_return()==Constant.ME){
                                if (order.getIs_return()==Constant.YES){
                                    holder3.title_info.setText("我赔付，爽约金将退还到对方账户");
                                    holder3.whoPay.setImageResource(R.mipmap.wogaiqian);
                                }else {
                                    holder3.title_info.setText("我爽约，但对方未缴纳爽约金，不用赔付");
                                    holder3.whoPay.setImageResource(R.mipmap.wogaiqian);
                                }

                            }else {
                                Toast.makeText(context,"loseTarget返回出错",Toast.LENGTH_SHORT).show();
                            }
                        }else if (order.getWhy_return().equals("超时")){
                            if (order.getWho_return()==Constant.ME){
                                if (order.getIs_return()==Constant.YES){
                                    holder3.title_info.setText("我赔付，爽约金将退还到对方账户");
                                    holder3.whoPay.setImageResource(R.mipmap.wochaoshi);
                                }else {
                                    holder3.title_info.setText("我爽约，但对方未缴纳爽约金，不用赔付");
                                    holder3.whoPay.setImageResource(R.mipmap.wochaoshi);
                                }

                            }else {
                                if (order.getIs_return()==Constant.YES){
                                    holder3.title_info.setText("对方赔付，爽约金稍后回到您的账户");
                                    holder3.whoPay.setImageResource(R.mipmap.duifangchaoshi);
                                }else {
                                    holder3.title_info.setText("对方爽约，但对方未缴纳爽约金，无赔付金额");
                                    holder3.whoPay.setImageResource(R.mipmap.duifangchaoshi);
                                }

                            }
                        }

                   if (order.getWho_created()==Constant.HOST){
                       holder3.words.setText("我的留言："+order.getWords());
                       holder3.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chengke),null,null,null);
                       holder3.text.setText("座位需求");
                   }else {
                       holder3.words.setText("车主留言："+order.getWords());
                       holder3.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chezhu),null,null,null);
                       holder3.text.setText("提供座位");

                   }

                   break;
               case Constant.EXCEPTION:
                   ViewHolderException holder4=null;
                   if (view==null){
                       view=inflater.inflate(R.layout.passenger_exception_long_item,null);
                       holder4=new ViewHolderException();
                       holder4.cancel_appeal=(TextView)view.findViewById(R.id.btn_cancel_appeal);
                       holder4.departTime=(TextView) view.findViewById(R.id.tv_depart_time);
                       holder4.end_pos=(TextView)view.findViewById(R.id.tv_end_pos);
                       holder4.icon=(CircleImage) view.findViewById(R.id.iv_icon);
                       holder4.loss=(TextView)view.findViewById(R.id.tv_loss_money);
                       holder4.nickname=(TextView)view.findViewById(R.id.tv_nickname);
                       holder4.seats=(TextView)view.findViewById(R.id.tv_transfer_fee);
                       holder4.start_pos=(TextView)view.findViewById(R.id.tv_start_pos);
                       holder4.text=(TextView)view.findViewById(R.id.tv_text);
                       holder4.title_info=(TextView)view.findViewById(R.id.tv_title_info);
                       holder4.total_price=(TextView)view.findViewById(R.id.tv_total_price);
                       holder4.words=(TextView)view.findViewById(R.id.tv_words);
                       view.setTag(holder4);
                   }else {
                       holder4=(ViewHolderException)view.getTag();
                   }
                   Picasso.with(context).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(holder4.icon);
                   holder4.start_pos.setText(order.getStart_place());
                   holder4.end_pos.setText(order.getEnd_place());
                   holder4.seats.setText(order.getSeats()+"个");
                   holder4.total_price.setText(order.getTotal_money()+"元");
                   holder4.departTime.setText(order.getDepart_time());
                   holder4.loss.setText(order.getLoss_money()+"元");
                   if (TextUtils.isEmpty(order.getNickname())){
                       holder4.nickname.setText("暂无昵称");
                   }else {
                       holder4.nickname.setText(order.getNickname());
                   }
                   if (order.getIs_reply()==Constant.YES){
                        holder4.title_info.setText("订单异常—客服已回复，查看详情");
                    }else {
                        holder4.title_info.setText("订单异常，等待客服处理");
                    }

                   if (order.getWho_created()==Constant.HOST){
                       holder4.words.setText("我的留言："+order.getWords());
                       holder4.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chengke),null,null,null);
                       holder4.text.setText("座位需求");
                   }else {
                       holder4.words.setText("车主留言："+order.getWords());
                       holder4.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chezhu),null,null,null);
                       holder4.text.setText("提供座位");

                   }
                   holder4.cancel_appeal.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View view) {
                           //Toast.makeText(context,"取消申诉 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                           onOrderHandleListener.onCancelAppeal(order.getOrder_id(),i,Constant.CANCEL_APPEAL);
                       }
                   });
                   break;
           }
        }else if (identity==Constant.HOST&&go_type!=Constant.LONG_HURRY){
            switch (order_type){
                case Constant.WAIT_PAY:
                    ViewHolderHost holderHost=null;
                    if (view==null){
                        view=inflater.inflate(R.layout.host_wait_pay_long_item,null);
                        holderHost=new ViewHolderHost();
                        holderHost.title_info=(TextView)view.findViewById(R.id.tv_title_info);
                        holderHost.title_money=(TextView)view.findViewById(R.id.tv_title_money);
                        holderHost.icon=(CircleImage) view.findViewById(R.id.iv_icon);
                        holderHost.nickname=(TextView)view.findViewById(R.id.tv_nickname);
                        holderHost.recent_come=(TextView)view.findViewById(R.id.tv_recent_come);
                        holderHost.words=(TextView)view.findViewById(R.id.tv_words);
                        holderHost.start_pos=(TextView)view.findViewById(R.id.tv_start_pos);
                        holderHost.end_pos=(TextView)view.findViewById(R.id.tv_end_pos);
                        holderHost.seats=(TextView)view.findViewById(R.id.tv_transfer_fee);
                        holderHost.total_price=(TextView)view.findViewById(R.id.tv_total_price);
                        holderHost.departTime=(TextView)view.findViewById(R.id.tv_depart_time);
                        holderHost.btn_release=(TextView) view.findViewById(R.id.btn_release);
                        holderHost.ll_owner_info=(LinearLayout)view.findViewById(R.id.ll_owner_info);
                        holderHost.line=(View)view.findViewById(R.id.title_line);
                        holderHost.tv_words_release=(TextView)view.findViewById(R.id.tv_words_release);
                        holderHost.loss=(TextView)view.findViewById(R.id.tv_loss);
                        view.setTag(holderHost);
                    }else {
                        holderHost=(ViewHolderHost)view.getTag();
                    }
                    holderHost.title_money.setText("爽约金"+order.getLoss_money()+"元");
                    holderHost.total_price.setText("");
                    holderHost.start_pos.setText(order.getStart_place());
                    holderHost.end_pos.setText(order.getEnd_place());
                    holderHost.seats.setText(order.getSeats()+"个");
                    holderHost.total_price.setText(order.getTotal_money()+"元");
                    holderHost.loss.setText(order.getLoss_money()+"元");
                    holderHost.departTime.setText(order.getDepart_time());
                    if (order.getIs_timeout()==Constant.YES){
                        holderHost.title_info.setText("已超时，需支付");
                        if (order.getForm_way()==Constant.RELEASE){
                            holderHost.btn_release.setText("重新发布");
                            holderHost.tv_words_release.setText("我的留言："+order.getWords());
                            holderHost.ll_owner_info.setVisibility(View.GONE);
                            holderHost.line.setVisibility(View.GONE);
                            holderHost.tv_words_release.setVisibility(View.VISIBLE);
                        }else {
                            holderHost.btn_release.setVisibility(View.GONE);
                            holderHost.tv_words_release.setVisibility(View.GONE);
                            holderHost.line.setVisibility(View.VISIBLE);
                            holderHost.ll_owner_info.setVisibility(View.VISIBLE);
                            Picasso.with(context).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(holderHost.icon);
                            holderHost.nickname.setText(order.getNickname());
                            holderHost.recent_come.setText("[24h前来过]");// TODO: 2017/11/13 喂一下相关
                            if (TextUtils.isEmpty(order.getWords())){
                                holderHost.words.setText("乘客留言：乘客很懒，没有留言");
                            }else {
                                holderHost.words.setText("乘客留言："+order.getWords());
                            }
                        }
                    }else {
                        if (order.getForm_way()==Constant.RELEASE){//信息未发布
                            holderHost.line.setVisibility(View.GONE);
                            holderHost.tv_words_release.setVisibility(View.VISIBLE);
                            holderHost.ll_owner_info.setVisibility(View.GONE);
                            holderHost.btn_release.setText("立即发布");
                            holderHost.title_info.setText("信息未发布，需支付");
                            holderHost.tv_words_release.setText("我的留言："+order.getWords());
                            Log.d("wp_title_info",holderHost.title_info.getText().toString()+holderHost.btn_release.getText().toString());

                        }else if (order.getForm_way()==Constant.BUY){//未购票
                            holderHost.line.setVisibility(View.VISIBLE);
                            holderHost.tv_words_release.setVisibility(View.GONE);
                            holderHost.ll_owner_info.setVisibility(View.VISIBLE);
                            holderHost.title_info.setText("抢单未成功，需支付");
                            holderHost.btn_release.setText("立即抢单");
                            Picasso.with(context).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(holderHost.icon);
                            holderHost.nickname.setText(order.getNickname());
                            holderHost.recent_come.setText("[24h前来过]");// TODO: 2017/11/13 喂一下相关
                            if (TextUtils.isEmpty(order.getWords())){
                                holderHost.words.setText("乘客留言：乘客很懒，没有留言");
                            }else {
                                holderHost.words.setText("乘客留言："+order.getWords());
                            }                        }
                    }


                    holderHost.btn_release.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (order.getIs_timeout()==Constant.YES){
                               // Toast.makeText(context,"重新发布"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                if (order.getForm_way()==Constant.RELEASE){
                                    Intent intent = new Intent(context, ReleaseActivity.class);
                                    intent.putExtra("identity",identity);
                                    context.startActivity(intent);
                                }else {

                                }
                            }else {
                                if (order.getForm_way()==Constant.RELEASE){
                                    //Toast.makeText(context,"立即发布"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                    //调用车主发布生成订单接口，跳转支付页面
                                    Intent intent = new Intent(context, BookPayActivity.class);
                                    intent.putExtra("orderCode",order.getOrder_id());
                                    intent.putExtra("amount", order.getLoss_money()+"");
                                    intent.putExtra("from", Constant.HOST_PUBLISH_PAY);
                                    intent.putExtra("id",order.getService_id());
                                    intent.putExtra("alipay",Common.HOST_PUBLISH_ALIPAY);
                                    intent.putExtra("yivipay",Common.HOST_PUBLISH_RESTPAY);
                                    context.startActivity(intent);
                                }else {
                                    //Toast.makeText(context,"立即抢单"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                    //调用车主抢单生成订单接口，跳转支付页面
                                    Intent intent = new Intent(context, BookPayActivity.class);
                                    intent.putExtra("orderCode",order.getOrder_id());
                                    intent.putExtra("amount", order.getLoss_money()+"");
                                    intent.putExtra("from", Constant.HOST_ROB_PAY);
                                    intent.putExtra("id",order.getService_id());
                                    intent.putExtra("alipay",Common.HOST_SEARCH_ALIPAY);
                                    intent.putExtra("yivipay",Common.HOST_SEARCH_RESTPAY);
                                    context.startActivity(intent);
                                }
                            }

                        }
                    });



                    break;
                case Constant.WAIT_TAKE:
                    ViewHolderWaitTakeHost holder1=null;
                    if (view==null){
                        view=inflater.inflate(R.layout.host_wait_take_long_item,null);
                        holder1=new ViewHolderWaitTakeHost();
                        holder1.title_info=(TextView)view.findViewById(R.id.tv_title_info);
                        holder1.words=(TextView)view.findViewById(R.id.tv_words);
                        holder1.start_pos=(TextView)view.findViewById(R.id.tv_start_pos);
                        holder1.end_pos=(TextView)view.findViewById(R.id.tv_end_pos);
                        holder1.seats=(TextView)view.findViewById(R.id.tv_transfer_fee);
                        holder1.total_price=(TextView)view.findViewById(R.id.tv_total_price);
                        holder1.loss=(TextView)view.findViewById(R.id.tv_loss_money);
                        holder1.price=(TextView)view.findViewById(R.id.tv_price);
                        holder1.departTime=(TextView)view.findViewById(R.id.tv_depart_time);
                        holder1.button1=(TextView)view.findViewById(R.id.button1);
                        holder1.button2=(TextView)view.findViewById(R.id.button2);
                        view.setTag(holder1);
                    }else {
                        holder1= (ViewHolderWaitTakeHost) view.getTag();
                    }
                    holder1.title_info.setTextColor(context.getResources().getColor(R.color.color_offline));
                    holder1.title_info.setText("剩余票数"+order.getRest_tickets()+"张");
                    holder1.seats.setText(order.getSeats()+"个");
                    holder1.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chezhu),null,null,null);
                    // TODO: 2017/11/16
                    if (TextUtils.isEmpty(order.getWords())){
                        holder1.words.setText("我的留言：没有留言");

                    }else {
                        holder1.words.setText("我的留言："+order.getWords());

                    }
                    holder1.start_pos.setText(order.getStart_place());
                    holder1.end_pos.setText(order.getEnd_place());
                    holder1.price.setText(order.getSingle_money()+"元");
                    holder1.total_price.setText(order.getTotal_money()+"元");
                    holder1.loss.setText(order.getLoss_money()+"元");
                    holder1.departTime.setText(order.getDepart_time());
                    if (order.getIs_timeout()==Constant.YES){
                        holder1.title_info.setText("已超时，剩余票数"+order.getRest_tickets()+"张");
                        holder1.button1.setText("取消订单");
                        holder1.button2.setText("再次发布");
                    }else{
                        holder1.title_info.setText("剩余票数"+order.getRest_tickets()+"张");
                        if (order.getIs_sale_start()==Constant.YES){
                            holder1.button1.setText("停止售票");
                            holder1.button2.setText("取消订单");
                        }else {
                            holder1.button1.setText("开始售票");
                            holder1.button2.setText("取消订单");
                        }

                    }
                    holder1.button1.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (order.getIs_timeout()==Constant.YES){
                                //Toast.makeText(context,"取消订单"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                //退未售出票数爽约金，判定服务无效
                                onOrderHandleListener.onCancelOrder(order.getForm_way()+"",order_type+"",order.getOrder_id()+"",i,Constant.CANCEL_ORDER);

                            }else {
                                if (order.getIs_sale_start()==Constant.YES){
                                    onOrderHandleListener.onEndSellTicket(order.getService_id(),order.getIs_sale_start()+"",Constant.END_SELL,i);
                                    //Toast.makeText(context,"停止售票"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                }else {
                                    onOrderHandleListener.onStartSellTicket(order.getService_id(),order.getIs_sale_start()+"",Constant.START_SELL,i);
                                    //Toast.makeText(context,"开始售票"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                }
                                //调用接口，成功之后改变按钮状态，即是否对乘客可见，乘客购买座位之后，待服务中多出一条订单
                            }

                        }
                    });
                    holder1.button2.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (order.getIs_timeout()==Constant.YES){
                               // Toast.makeText(context,"再次发布"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                //退未售出票数的爽约金，跳转重新发布页面
                                Intent intent = new Intent(context, ReleaseActivity.class);
                                intent.putExtra("identity",identity);
                                context.startActivity(intent);
                            }else {
                                //退未售出票数爽约金，判定服务无效
                            }

                        }
                    });

                    break;
                case Constant.WAIT_SURVICE:
                case Constant.IN_SURVICE:
                case Constant.WAIT_FINISH:
                case Constant.FINISHED:
                    ViewHolderWaitSurviceHost holder2=null;
                    if (view==null){
                        view=inflater.inflate(R.layout.host_wait_survice_long_item,null);
                        holder2=new ViewHolderWaitSurviceHost();
                        holder2.icon=(CircleImage) view.findViewById(R.id.iv_icon);
                        holder2.nickname=(TextView)view.findViewById(R.id.tv_nickname);
                        holder2.recent_come =(TextView)view.findViewById(R.id.tv_recent_come);
                        holder2.words=(TextView)view.findViewById(R.id.tv_words);
                        holder2.start_pos=(TextView)view.findViewById(R.id.tv_start_pos);
                        holder2.end_pos=(TextView)view.findViewById(R.id.tv_end_pos);
                        holder2.seats=(TextView)view.findViewById(R.id.tv_transfer_fee);
                        holder2.total_price=(TextView)view.findViewById(R.id.tv_total_price);
                        holder2.loss=(TextView)view.findViewById(R.id.tv_loss_money);
                        holder2.departTime=(TextView)view.findViewById(R.id.tv_depart_time);
                        holder2.button1 =(TextView)view.findViewById(R.id.button1);
                        holder2.button2=(TextView)view.findViewById(R.id.button2);
                        holder2.text=(TextView)view.findViewById(R.id.text);

                        holder2.line=(View)view.findViewById(R.id.line);
                        holder2.title_info=(TextView)view.findViewById(R.id.tv_title_info);

                        holder2.ll_loss=(LinearLayout)view.findViewById(R.id.ll_loss);
                        holder2.button3=(TextView)view.findViewById(R.id.button3);
                        view.setTag(holder2);
                    }else {
                        holder2= (ViewHolderWaitSurviceHost) view.getTag();
                    }
                    Picasso.with(context).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(holder2.icon);
                    if(TextUtils.isEmpty(order.getNickname())){
                        holder2.nickname.setText("暂无昵称");
                    }else {
                        holder2.nickname.setText(order.getNickname());
                    }
                    holder2.recent_come.setText("[24h前来过]");// TODO: 2017/11/14 喂一下

                    if (order.getWho_created()==Constant.HOST){
                        holder2.words.setText("乘客留言："+order.getWords());
                        holder2.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chengke),null,null,null);
                        holder2.text.setText("座位需求");
                    }else {
                        holder2.words.setText("我的留言："+order.getWords());
                        holder2.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chezhu),null,null,null);
                        holder2.text.setText("提供座位");
                    }

                    holder2.start_pos.setText(order.getStart_place());
                    holder2.end_pos.setText(order.getEnd_place());
                    holder2.seats.setText(order.getSeats()+"个");
                    holder2.total_price.setText(order.getTotal_money()+"元");
                    holder2.departTime.setText(order.getDepart_time());
                    if (order_type==Constant.WAIT_SURVICE){
                        holder2.ll_loss.setVisibility(View.VISIBLE);
                        holder2.line.setVisibility(View.GONE);
                        holder2.title_info.setVisibility(View.GONE);
                        holder2.loss.setText(order.getLoss_money()+"元");
                        holder2.button1.setText("开始服务");

                    }else if (order_type==Constant.IN_SURVICE){
                        holder2.ll_loss.setVisibility(View.GONE);
                        holder2.line.setVisibility(View.GONE);
                        holder2.title_info.setVisibility(View.GONE);
                        holder2.button1.setText("行程完结");
                    }else if (order_type==Constant.WAIT_FINISH){
                        holder2.ll_loss.setVisibility(View.GONE);
                        if (order.getIs_finished()==Constant.HOST_FINISHED_PASSENGER_NO){//等待对方完结
                            holder2.button1.setVisibility(View.GONE);
                            holder2.line.setVisibility(View.VISIBLE);
                            holder2.title_info.setVisibility(View.VISIBLE);
                            holder2.title_info.setText("等待对方完结");

                        }else if (order.getIs_finished()==Constant.PASSENGER_FINISHED_HOST_NO){
                            holder2.button1.setVisibility(View.VISIBLE);
                            holder2.button1.setText("行程完结");
                            holder2.line.setVisibility(View.GONE);
                            holder2.title_info.setVisibility(View.GONE);
                        }

                    }else if (order_type==Constant.FINISHED){
                        holder2.ll_loss.setVisibility(View.GONE);
                        holder2.button1.setVisibility(View.VISIBLE);
                        holder2.button1.setText("再次发布");
                        holder2.line.setVisibility(View.GONE);
                        holder2.title_info.setVisibility(View.GONE);
                    }


                    holder2.button1.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            switch (order_type){
                                case Constant.WAIT_SURVICE:
                                    onOrderHandleListener.onStartService(order.getOrder_id(),Constant.START_SERVICE,i);
                                    break;
                                case Constant.IN_SURVICE:
                                   // Toast.makeText(context,"服务中行程完结"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                    onOrderHandleListener.onRouteFinish(identity+"",order.getOrder_id(),i,Constant.ROUTE_FINISHED);

                                    break;
                                case Constant.WAIT_FINISH:
                                   // Toast.makeText(context,"待完结行程完结"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                    onOrderHandleListener.onRouteFinish(identity+"",order.getOrder_id(),i,Constant.ROUTE_FINISHED);

                                    break;
                                case Constant.FINISHED:
                                    //Toast.makeText(context,"再次发布"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                                    Intent intent = new Intent(context, ReleaseActivity.class);
                                    intent.putExtra("identity",identity);
                                    context.startActivity(intent);
                                    break;
                            }

                        }
                    });
                    holder2.button2.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (!TextUtils.isEmpty(order.getPhone())){
                                CallPhone.callPhone(context,order.getPhone());
                            }else {
                                Toast.makeText(context,"电话为空",Toast.LENGTH_LONG).show();
                            }

                        }
                    });
                    holder2.button3.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            //Toast.makeText(context,"喂一下"+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                            Toast.makeText(context,"暂未开放",Toast.LENGTH_LONG).show();


                        }
                    });

                    break;
                case Constant.LOSS:
                    ViewHolderLoss holder3=null;
                    if (view==null){
                        view=inflater.inflate(R.layout.passenger_loss_long_item,null);
                        holder3=new ViewHolderLoss();
                        holder3.icon=(CircleImage) view.findViewById(R.id.iv_icon);
                        holder3.nickname=(TextView)view.findViewById(R.id.tv_nickname);
                        holder3.words=(TextView)view.findViewById(R.id.tv_words);
                        holder3.start_pos=(TextView)view.findViewById(R.id.tv_start_pos);
                        holder3.end_pos=(TextView)view.findViewById(R.id.tv_end_pos);
                        holder3.seats=(TextView)view.findViewById(R.id.tv_transfer_fee);
                        holder3.total_price=(TextView)view.findViewById(R.id.tv_total_price);
                        holder3.loss=(TextView)view.findViewById(R.id.tv_loss_money);
                        holder3.departTime=(TextView)view.findViewById(R.id.tv_depart_time);
                        holder3.whoPay=(ImageView)view.findViewById(R.id.iv_whoPay);

                        holder3.title_info=(TextView)view.findViewById(R.id.tv_title_info);
                        holder3.text=(TextView)view.findViewById(R.id.tv_text);

                        view.setTag(holder3);
                    }else {
                        holder3= (ViewHolderLoss) view.getTag();
                    }
                    Picasso.with(context).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(holder3.icon);
                    holder3.nickname.setText(order.getNickname());
                    if (order.getVehicle_type()==Constant.BUS){
                        holder3.nickname.setCompoundDrawablesWithIntrinsicBounds(null,null,context.getResources().getDrawable(R.mipmap.bus),null);
                    }else {
                        holder3.nickname.setCompoundDrawablesWithIntrinsicBounds(null,null,context.getResources().getDrawable(R.mipmap.car1),null);
                    }
                    holder3.start_pos.setText(order.getStart_place());
                    holder3.end_pos.setText(order.getEnd_place());
                    holder3.seats.setText(order.getSeats()+"个");
                    holder3.total_price.setText(order.getTotal_money()+"元");
                    holder3.loss.setText(order.getLoss_money()+"元");
                    holder3.departTime.setText(order.getDepart_time());
                    if (order.getIs_return()==Constant.YES&&order.getWho_return()==Constant.ME){
                        holder3.title_info.setText("我赔付，爽约金将退还到对方账户");
                        holder3.whoPay.setImageResource(R.mipmap.wotuipiao);
                    }else if (order.getIs_return()==Constant.YES&&order.getWho_return()==Constant.NOT_ME){
                        holder3.title_info.setText("对方赔付，爽约金稍后回到您的账户");
                        holder3.whoPay.setImageResource(R.mipmap.duifangtuipiao);
                    }
                        if (order.getWhy_return().equals("退票")){
                            if (order.getWho_return()==Constant.ME){
                                if (order.getIs_return()==Constant.YES){
                                    holder3.title_info.setText("我赔付，爽约金将退还到对方账户");
                                    holder3.whoPay.setImageResource(R.mipmap.wotuipiao);
                                }else {
                                    holder3.title_info.setText("我爽约，但我免缴爽约金，不用赔付");
                                    holder3.whoPay.setImageResource(R.mipmap.wotuipiao);
                                }

                            }else {
                                if (order.getIs_return()==Constant.YES){
                                    holder3.title_info.setText("对方赔付，爽约金稍后回到您的账户");
                                    holder3.whoPay.setImageResource(R.mipmap.duifangtuipiao);
                                }else {
                                    holder3.title_info.setText("对方爽约，但我免缴爽约金，无赔付金额");
                                    holder3.whoPay.setImageResource(R.mipmap.duifangtuipiao);
                                }

                            }
                        }else if (order.getWhy_return().equals("改签")){
                            if (order.getWho_return()==Constant.ME){
                                Toast.makeText(context,"loseTarget返回出错",Toast.LENGTH_SHORT).show();
                            }else {
                                if (order.getIs_return()==Constant.YES){
                                    holder3.title_info.setText("对方赔付，爽约金将退还到您的账户");
                                    holder3.whoPay.setImageResource(R.mipmap.duifanggaiqian);
                                }else {
                                    holder3.title_info.setText("对方爽约，但我免缴爽约金，无赔付金额");
                                    holder3.whoPay.setImageResource(R.mipmap.duifanggaiqian);
                                }

                            }
                        }else if (order.getWhy_return().equals("超时")){
                            if (order.getWho_return()==Constant.ME){
                                if (order.getIs_return()==Constant.YES){
                                    holder3.title_info.setText("我赔付，爽约金将退还到对方账户");
                                    holder3.whoPay.setImageResource(R.mipmap.wochaoshi);
                                }else {
                                    holder3.title_info.setText("我爽约，但我免缴爽约金，不用赔付");
                                    holder3.whoPay.setImageResource(R.mipmap.wochaoshi);
                                }

                            }else {
                                if (order.getIs_return()==Constant.YES){
                                    holder3.title_info.setText("对方赔付，爽约金稍后回到您的账户");
                                    holder3.whoPay.setImageResource(R.mipmap.duifangchaoshi);
                                }else {
                                    holder3.title_info.setText("对方爽约，但我免缴爽约金，无赔付金额");
                                    holder3.whoPay.setImageResource(R.mipmap.wochaoshi);
                                }

                            }
                        }

                    if (order.getWho_created()==Constant.HOST){
                        holder3.words.setText("乘客留言："+order.getWords());
                        holder3.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chengke),null,null,null);
                        holder3.text.setText("座位需求");
                    }else {
                        holder3.words.setText("我的留言："+order.getWords());
                        holder3.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chezhu),null,null,null);
                        holder3.text.setText("座位需求");
                    }

                    break;
                case Constant.EXCEPTION:
                    ViewHolderException holder4=null;
                    if (view==null){
                        view=inflater.inflate(R.layout.passenger_exception_long_item,null);
                        holder4=new ViewHolderException();
                        holder4.cancel_appeal=(TextView) view.findViewById(R.id.btn_cancel_appeal);
                        holder4.departTime=(TextView) view.findViewById(R.id.tv_depart_time);
                        holder4.end_pos=(TextView)view.findViewById(R.id.tv_end_pos);
                        holder4.icon=(CircleImage) view.findViewById(R.id.iv_icon);
                        holder4.loss=(TextView)view.findViewById(R.id.tv_loss_money);
                        holder4.nickname=(TextView)view.findViewById(R.id.tv_nickname);
                        holder4.seats=(TextView)view.findViewById(R.id.tv_transfer_fee);
                        holder4.start_pos=(TextView)view.findViewById(R.id.tv_start_pos);
                        holder4.text=(TextView)view.findViewById(R.id.tv_text);
                        holder4.title_info=(TextView)view.findViewById(R.id.tv_title_info);
                        holder4.total_price=(TextView)view.findViewById(R.id.tv_total_price);
                        holder4.words=(TextView)view.findViewById(R.id.tv_words);
                        view.setTag(holder4);
                    }else {
                        holder4=(ViewHolderException)view.getTag();
                    }
                    Picasso.with(context).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(holder4.icon);

                    holder4.start_pos.setText(order.getStart_place());
                    holder4.end_pos.setText(order.getEnd_place());
                    holder4.seats.setText(order.getSeats()+"个");
                    holder4.total_price.setText(order.getTotal_money()+"元");
                    holder4.departTime.setText(order.getDepart_time());
                    holder4.loss.setText(order.getLoss_money()+"元");
                    if (TextUtils.isEmpty(order.getNickname())){
                        holder4.nickname.setText("暂无昵称");
                    }else {
                        holder4.nickname.setText(order.getNickname());
                    }
                    if (order.getIs_reply()==Constant.YES){
                        holder4.title_info.setText("订单异常—客服已回复，查看详情");
                    }else {
                        holder4.title_info.setText("订单异常，等待客服处理");
                    }

                    if (order.getWho_created()==Constant.HOST){
                        holder4.words.setText("乘客留言："+order.getWords());
                        holder4.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chengke),null,null,null);
                        holder4.text.setText("座位需求");
                    }else {
                        holder4.words.setText("我的留言："+order.getWords());
                        holder4.words.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chezhu),null,null,null);
                        holder4.text.setText("座位需求");
                    }
                    holder4.cancel_appeal.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            //Toast.makeText(context,"取消申诉 "+"身份"+identity+"订单类型"+order_type+"出行方式"+go_type+"第"+i+"条",Toast.LENGTH_LONG).show();
                        }
                    });
                    break;
            }
        }else if (go_type==Constant.LONG_HURRY){
            //乘客长途急件
                    VHP holder=null;
                    if (view==null){
                        view=inflater.inflate(R.layout.passenger_long_hurry_item,null);
                        holder=new VHP();
                        holder.titleInfo=(TextView)view.findViewById(R.id.text1);
                        holder.titleMoney=(TextView)view.findViewById(R.id.text2);
                        holder.titleLine=view.findViewById(R.id.line1);
                        holder.icon=(CircleImage) view.findViewById(R.id.iv_icon);
                        holder.nickname=(TextView)view.findViewById(R.id.tv_nickname);
                        holder.recentCome=(TextView)view.findViewById(R.id.tv_recent_come);
                        holder.myWords=(TextView)view.findViewById(R.id.tv_words);
                        holder.hostWords=(TextView)view.findViewById(R.id.tv_words_release);
                        holder.transferFee=(TextView)view.findViewById(R.id.tv_transfer_fee);
                        holder.spaceCalled=(TextView)view.findViewById(R.id.text3);
                        holder.num =(TextView)view.findViewById(R.id.tv_num);
                        holder.spaceType=(TextView)view.findViewById(R.id.tv_space_type);
                        holder.baojia=(TextView)view.findViewById(R.id.tv_baojia);
                        holder.departTime=(TextView)view.findViewById(R.id.tv_depart_time);
                        holder.button1=(TextView)view.findViewById(R.id.button1);
                        holder.button2=(TextView)view.findViewById(R.id.button2);
                        holder.ll_owner_info=(LinearLayout)view.findViewById(R.id.ll_owner_info);
                        holder.startPos=(TextView)view.findViewById(R.id.tv_start_pos);
                        holder.endPos=(TextView)view.findViewById(R.id.tv_end_pos);
                        holder.button3=(TextView)view.findViewById(R.id.button3);
                        holder.baofei=(TextView)view.findViewById(R.id.tv_baofei);
                        holder.whoPay=(ImageView)view.findViewById(R.id.iv_whoPay);
                        holder.text=(TextView)view.findViewById(R.id.text);
                        holder.ll_baojia=(LinearLayout)view.findViewById(R.id.ll_baojia);
                        view.setTag(holder);
                    }else {
                        holder=(VHP)view.getTag();
                    }
                    Picasso.with(context).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(holder.icon);
                    switch (order_type){
                        case Constant.WAIT_PAY:
                            if (identity==Constant.PASSENGER){
                                holder.button1.setVisibility(View.GONE);
                                holder.button2.setText("取消订单");
                                if (order.getIs_timeout()==Constant.YES){
                                    holder.titleInfo.setText("已超时，运费+保费，");
                                    holder.titleLine.setVisibility(View.GONE);
                                    holder.ll_owner_info.setVisibility(View.GONE);
                                    holder.spaceCalled.setText("体积相当于");
                                    holder.button3.setText("重新发布");
                                }else {
                                    if (order.getForm_way()==Constant.RELEASE){
                                        holder.titleInfo.setText("信息未发布，运费+保费，");
                                        holder.titleLine.setVisibility(View.GONE);
                                        holder.ll_owner_info.setVisibility(View.GONE);
                                        holder.spaceCalled.setText("体积相当于");
                                        holder.button3.setText("立即发布");
                                    }else if (order.getForm_way()==Constant.BUY){
                                        holder.titleInfo.setText("订仓未成功，运费+保费，");
                                        holder.myWords.setVisibility(View.GONE);
                                        holder.spaceCalled.setText("可在控件相当于");
                                        holder.button3.setText("立即订仓");
                                        if (order.getVehicle_type()==Constant.BUS){
                                            holder.nickname.setCompoundDrawablesWithIntrinsicBounds(null,null,context.getResources().getDrawable(R.mipmap.bus),null);
                                        }else {
                                            holder.nickname.setCompoundDrawablesWithIntrinsicBounds(null,null,context.getResources().getDrawable(R.mipmap.car1),null);

                                        }
                                    }
                                }
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-待付款-长途急件-取消订单 第"+i+"条",Toast.LENGTH_SHORT).show();
                                    }
                                });
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (order.getIs_timeout()==Constant.YES){
                                            Toast.makeText(context,"乘客-待付款-长途急件-重新发布 第"+i+"条",Toast.LENGTH_SHORT).show();

                                        }else {
                                            if (order.getForm_way()==Constant.RELEASE){
                                                Toast.makeText(context,"乘客-待付款-长途急件-立即发布 第"+i+"条",Toast.LENGTH_SHORT).show();

                                            }else {
                                                Toast.makeText(context,"乘客-待付款-长途急件-立即订仓 第"+i+"条",Toast.LENGTH_SHORT).show();

                                            }
                                        }
                                    }
                                });
                            }else {
                                holder.button1.setVisibility(View.GONE);
                                holder.button2.setText("取消订单");
                                if (order.getIs_timeout()==Constant.YES){
                                    holder.titleInfo.setText("已超时，需支付：爽约金");
                                    holder.ll_owner_info.setVisibility(View.GONE);
                                    holder.titleLine.setVisibility(View.GONE);
                                    holder.button3.setText("再次发布");
                                    holder.text.setText("爽约金");
                                }else {
                                    if (order.getForm_way()==Constant.RELEASE){
                                        holder.titleInfo.setText("信息未发布，需支付：爽约金");
                                        holder.ll_owner_info.setVisibility(View.GONE);
                                        holder.titleLine.setVisibility(View.GONE);
                                        holder.button3.setText("立即发布");
                                        holder.text.setText("爽约金");
                                    }else {
                                        holder.titleInfo.setText("抢单未成功，需支付：爽约金");
                                        holder.button3.setText("立即抢单");
                                        holder.hostWords.setVisibility(View.GONE);

                                    }
                                }
                            }
                            holder.button2.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    Toast.makeText(context,"车主-待付款-长途急件-取消订单 第"+i+"条",Toast.LENGTH_SHORT).show();
                                }
                            });
                            holder.button3.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (order.getIs_timeout()==Constant.YES){
                                        Toast.makeText(context,"车主-待付款-长途急件-再次发布 第"+i+"条",Toast.LENGTH_SHORT).show();
                                        Intent intent = new Intent(context, ReleaseActivity.class);
                                        intent.putExtra("identity",identity);
                                        context.startActivity(intent);

                                    }else {
                                        if (order.getForm_way()==Constant.RELEASE){
                                            Toast.makeText(context,"车主-待付款-长途急件-立即发布 第"+i+"条",Toast.LENGTH_SHORT).show();

                                        }else {
                                            Toast.makeText(context,"车主-待付款-长途急件-立即抢单 第"+i+"条",Toast.LENGTH_SHORT).show();

                                        }
                                    }
                                }
                            });


                            break;
                        case Constant.WAIT_TAKE:
                            if (identity==Constant.PASSENGER){
                                holder.titleInfo.setText("等待车主接单");
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.titleLine.setVisibility(View.GONE);
                                holder.myWords.setText("留言:"+order.getWords());
                                holder.myWords.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.mipmap.chengke),null,null,null);
                                holder.ll_owner_info.setVisibility(View.GONE);
                                holder.button1.setVisibility(View.GONE);
                                holder.button3.setVisibility(View.GONE);
                                holder.button2.setText("取消订单");
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-待接单-长途急件-取消订单 第"+i+"条",Toast.LENGTH_SHORT).show();
                                    }
                                });
                            }else {
                                holder.titleInfo.setText("待乘客订仓，请耐心等待");
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.titleLine.setVisibility(View.GONE);
                                holder.ll_owner_info.setVisibility(View.GONE);
                                holder.button1.setVisibility(View.GONE);
                                holder.button2.setText("停止售仓");
                                holder.button3.setText("取消订单");
                                holder.ll_baojia.setVisibility(View.GONE);
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-待接单-长途急件-停止售仓 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-待接单-长途急件-取消订单 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });

                            }

                            break;
                        case Constant.WAIT_SURVICE:
                            if (identity==Constant.PASSENGER){
                                holder.titleInfo.setVisibility(View.GONE);
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.titleLine.setVisibility(View.GONE);
                                holder.hostWords.setVisibility(View.GONE);
                                holder.button1.setVisibility(View.GONE);
                                holder.button2.setText("电话");
                                holder.button3.setText("喂一下");
                                if (order.getForm_way()==Constant.RELEASE){
                                    holder.spaceCalled.setText("体积相当于");
                                    holder.myWords.setText("我的留言："+order.getWords());
                                }else if (order.getForm_way()==Constant.BUY){
                                    holder.spaceCalled.setText("可载空间相当于");
                                    holder.myWords.setText("车主留言："+order.getWords());
                                }
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-待服务-长途急件-电话 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-待服务-长途急件-喂一下 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                            }else {
                                holder.titleInfo.setVisibility(View.GONE);
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.titleLine.setVisibility(View.GONE);
                                holder.hostWords.setVisibility(View.GONE);
                                holder.button1.setText("开始服务");
                                holder.button2.setText("电话");
                                holder.button3.setText("喂一下");

                                holder.button1.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-待服务-长途急件-开始服务 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-待服务-长途急件-电话 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-待服务-长途急件-喂一下 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                            }

                            break;
                        case Constant.IN_SURVICE:
                            if (identity==Constant.PASSENGER){
                                holder.titleInfo.setVisibility(View.GONE);
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.titleLine.setVisibility(View.GONE);
                                holder.myWords.setVisibility(View.GONE);
                                holder.button2.setText("电话");
                                holder.button3.setText("喂一下");
                                if (order.getIn_service_state()==Constant.GOODS_IN_CAR){
                                    holder.button1.setText("货已上车");
                                }else if (order.getIn_service_state()==Constant.GOODS_ARRIVE){
                                    holder.button1.setText("货已送达");
                                }
                                if (order.getForm_way()==Constant.RELEASE){
                                    holder.spaceCalled.setText("体积相当于");
                                    holder.hostWords.setText("我的留言："+order.getWords());
                                }else if (order.getForm_way()==Constant.BUY){
                                    holder.spaceCalled.setText("可载空间相当于");
                                    holder.hostWords.setText("车主留言："+order.getWords());
                                }
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-服务中-长途急件-电话 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-服务中-长途急件-喂一下 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                            }else {
                                holder.titleInfo.setVisibility(View.GONE);
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.titleLine.setVisibility(View.GONE);
                                holder.hostWords.setVisibility(View.GONE);
                                holder.button1.setText("货已送达");
                                holder.button2.setText("电话");
                                holder.button3.setText("喂一下");
                                holder.button1.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-服务中-长途急件-货已送达 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-服务中-长途急件-电话 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-服务中-长途急件-喂一下 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                            }

                            break;
                        case Constant.WAIT_FINISH:
                            if (identity==Constant.PASSENGER){
                                holder.titleInfo.setVisibility(View.GONE);
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.titleLine.setVisibility(View.GONE);
                                holder.myWords.setVisibility(View.GONE);
                                holder.button2.setText("电话");
                                holder.button3.setText("喂一下");
                                if (order.getWait_finish_state()==Constant.WAIT_ME_FINISH){
                                    holder.button1.setText("确认送达");
                                    holder.titleInfo.setVisibility(View.VISIBLE);
                                    holder.titleInfo.setText("等待对方完结");
                                    holder.titleLine.setVisibility(View.VISIBLE);
                                }else if (order.getWait_finish_state()==Constant.WAIT_OTHER_FINISH){
                                    holder.button1.setVisibility(View.GONE);
                                }

                                if (order.getForm_way()==Constant.RELEASE){
                                    holder.spaceCalled.setText("体积相当于");
                                    holder.hostWords.setText("我的留言："+order.getWords());
                                }else if (order.getForm_way()==Constant.BUY){
                                    holder.spaceCalled.setText("可载空间相当于");
                                    holder.hostWords.setText("车主留言："+order.getWords());
                                }
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-待完结-长途急件-电话 第"+i+"条",Toast.LENGTH_SHORT).show();
                                    }
                                });
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-待完结-长途急件-喂一下 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button1.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-待完结-长途急件-确认送达 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                            }else {
                                holder.button2.setText("电话");
                                holder.button3.setText("喂一下");
                                if (order.getIs_finished()==Constant.HOST_FINISHED_PASSENGER_NO){
                                    holder.titleInfo.setText("等待对方完结");
                                    holder.titleMoney.setVisibility(View.GONE);
                                    holder.button1.setVisibility(View.GONE);
                                }else {
                                    holder.titleInfo.setVisibility(View.GONE);
                                    holder.titleMoney.setVisibility(View.GONE);
                                    holder.titleLine.setVisibility(View.GONE);
                                    holder.hostWords.setVisibility(View.GONE);
                                    holder.button1.setText("确认送达");
                                }
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-待完结-长途急件-电话 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-待完结-长途急件-喂一下 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button1.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-待完结-长途急件-确认送达 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                            }


                            break;
                        case Constant.FINISHED:
                            if (identity==Constant.PASSENGER){
                                holder.titleInfo.setVisibility(View.GONE);
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.titleLine.setVisibility(View.GONE);
                                holder.myWords.setVisibility(View.GONE);
                                holder.button2.setText("电话");
                                holder.button3.setText("喂一下");
                                holder.button1.setText("再次发布");
                                holder.baofei.setText("物品丢损，按此保价赔偿，保费8%");
                                holder.baofei.setTextColor(context.getResources().getColor(R.color.textcolorl));
                                if (order.getForm_way()==Constant.RELEASE){
                                    holder.spaceCalled.setText("体积相当于");
                                    holder.hostWords.setText("我的留言："+order.getWords());
                                }else if (order.getForm_way()==Constant.BUY){
                                    holder.spaceCalled.setText("可载空间相当于");
                                    holder.hostWords.setText("车主留言："+order.getWords());
                                }
                                holder.button1.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-已完结-长途急件-再次发布 第"+i+"条",Toast.LENGTH_SHORT).show();
                                        Intent intent = new Intent(context, ReleaseActivity.class);
                                        intent.putExtra("identity",identity);
                                        context.startActivity(intent);
                                    }
                                });
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-已完结-长途急件-电话 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"乘客-已完结-长途急件-喂一下 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                            }else {
                                holder.titleInfo.setVisibility(View.GONE);
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.titleLine.setVisibility(View.GONE);
                                holder.hostWords.setVisibility(View.GONE);
                                holder.button1.setText("再次发布");
                                holder.button2.setText("电话");
                                holder.button3.setText("喂一下");
                                holder.button1.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-已完结-长途急件-再次发布 第"+i+"条",Toast.LENGTH_SHORT).show();
                                        Intent intent = new Intent(context, ReleaseActivity.class);
                                        intent.putExtra("identity",identity);
                                        context.startActivity(intent);
                                    }
                                });
                                holder.button2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-已完结-长途急件-电话 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-已完结-长途急件-喂一下 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                            }


                            break;
                        case Constant.LOSS:
                            if (identity==Constant.PASSENGER){
                                holder.whoPay.setVisibility(View.VISIBLE);
                                if (order.getWho_return()==Constant.ME){
                                    holder.titleInfo.setText("我赔付，爽约金将补偿对方");
                                    holder.whoPay.setImageResource(R.mipmap.wotuipiao);
                                }else {
                                    holder.titleInfo.setText("对方赔付，爽约金稍后会到您的账户");
                                    holder.whoPay.setImageResource(R.mipmap.duifangtuipiao);

                                }
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.myWords.setVisibility(View.GONE);
                                if (order.getForm_way()==Constant.RELEASE){
                                    holder.spaceCalled.setText("体积相当于");
                                    holder.hostWords.setText("我的留言："+order.getWords());
                                }else if (order.getForm_way()==Constant.BUY){
                                    holder.spaceCalled.setText("可载空间相当于");
                                    holder.hostWords.setText("车主留言："+order.getWords());
                                }
                                holder.button1.setVisibility(View.GONE);
                                holder.button2.setVisibility(View.GONE);
                                holder.button3.setVisibility(View.GONE);
                                holder.recentCome.setVisibility(View.GONE);
                            }else {
                                holder.ll_owner_info.setVisibility(View.GONE);
                                holder.button2.setVisibility(View.GONE);
                                holder.button1.setVisibility(View.GONE);
                                holder.button3.setVisibility(View.GONE);
                                holder.whoPay.setVisibility(View.VISIBLE);
                                if (order.getWho_return()==Constant.PASSENGER){
                                    holder.titleInfo.setText("对方赔付，爽约金100元稍后会到您的账户");
                                    holder.whoPay.setImageResource(R.mipmap.duifangtuipiao);
                                }else {
                                    holder.titleInfo.setText("我赔付，爽约金将补偿对方");
                                    holder.whoPay.setImageResource(R.mipmap.wotuipiao);
                                }
                            }

                            break;
                        case Constant.EXCEPTION:
                            if (identity==Constant.PASSENGER){
                                if (order.getIs_reply()==Constant.YES){
                                    holder.titleInfo.setText("订单异常-客服已回复，查看详情");
                                }else {
                                    holder.titleInfo.setText("订单异常-正等待客服处理");
                                }
                                if (order.getForm_way()==Constant.RELEASE){
                                    holder.spaceCalled.setText("体积相当于");
                                    holder.hostWords.setText("我的留言："+order.getWords());
                                }else if (order.getForm_way()==Constant.BUY){
                                    holder.spaceCalled.setText("可载空间相当于");
                                    holder.hostWords.setText("车主留言："+order.getWords());
                                }
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.myWords.setVisibility(View.GONE);
                                holder.button3.setVisibility(View.GONE);
                                holder.button2.setVisibility(View.GONE);
                                holder.button1.setVisibility(View.GONE);
                                holder.baofei.setText("物品丢损，按此保价赔偿，保费8%");
                                holder.baofei.setTextColor(context.getResources().getColor(R.color.textcolorl));
                            }else {
                                holder.titleMoney.setVisibility(View.GONE);
                                holder.ll_owner_info.setVisibility(View.GONE);
                                holder.hostWords.setVisibility(View.GONE);
                                holder.button1.setVisibility(View.GONE);
                                holder.button2.setVisibility(View.GONE);
                                holder.button3.setText("取消申诉");
                                holder.button3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(context,"车主-订单异常-长途急件-取消申诉 第"+i+"条",Toast.LENGTH_SHORT).show();

                                    }
                                });
                            }
                            break;
                    }

        }


        return view;
    }


    /*
    * 乘客长途
    * */
    private class ViewHolder{//乘客，长途，待付款
        TextView title_info;
        TextView title_money;
        CircleImage icon;
        TextView nickname;
        TextView time;
        TextView words;
        TextView start_pos;
        TextView end_pos;
        TextView seats;
        TextView total_price;
        TextView departTime;
        TextView btnBuy;
        View line;
        TextView tv_words_release;
        LinearLayout ll_buy;
        LinearLayout ll_bottom_release;
        LinearLayout ll_bottom_buy;
        TextView release_again;

    }
    private class ViewHolderWaitTake{//待结单
        TextView title_info;
        TextView words;
        TextView start_pos;
        TextView end_pos;
        TextView seats;
        TextView total_price;
        TextView departTime;
        TextView btnCancel;
        TextView btnReleaseAgain;
    }
    private class ViewHolderWaitSurvice{
        CircleImage icon;
        TextView nickname;
        TextView recent_come;
        TextView words;
        TextView start_pos;
        TextView end_pos;
        TextView seats;
        TextView total_price;
        TextView loss;
        TextView departTime;
        TextView btnPhone;
        TextView btnWei;
        TextView btnInCar;
        TextView text;
        LinearLayout ll_loss;
        TextView title_info;
        View line;
    }
    private class ViewHolderLoss{
        CircleImage icon;
        TextView nickname;
        TextView words;
        TextView start_pos;
        TextView end_pos;
        TextView seats;
        TextView total_price;
        TextView loss;
        TextView departTime;
        ImageView whoPay;
        TextView title_info;
        TextView text;


    }
    private class ViewHolderException{
        CircleImage icon;
        TextView nickname;
        TextView words;
        TextView start_pos;
        TextView end_pos;
        TextView seats;
        TextView total_price;
        TextView loss;
        TextView departTime;
        TextView title_info;
        TextView text;
        TextView cancel_appeal;
    }
    /*
    * 车主长途
    * */
    private class ViewHolderHost{//车主，长途，待付款
        TextView title_info;
        TextView title_money;
        CircleImage icon;
        TextView nickname;
        TextView recent_come;
        TextView words;
        TextView start_pos;
        TextView end_pos;
        TextView seats;
        TextView total_price;
        TextView departTime;
        View line;
        TextView tv_words_release;
        LinearLayout ll_owner_info;
        TextView btn_release;
        TextView loss;

    }
    private class ViewHolderWaitTakeHost{//待结单
        TextView title_info;
        TextView words;
        TextView start_pos;
        TextView end_pos;
        TextView seats;
        TextView total_price;
        TextView price;
        TextView loss;
        TextView departTime;
        TextView button1;
        TextView button2;
    }
    private class ViewHolderWaitSurviceHost{
        CircleImage icon;
        TextView nickname;
        TextView recent_come;
        TextView words;
        TextView start_pos;
        TextView end_pos;
        TextView seats;
        TextView total_price;
        TextView loss;
        TextView departTime;
        TextView button1;
        TextView button2;
        TextView button3;
        TextView text;
        LinearLayout ll_loss;
        TextView title_info;
        View line;
    }
    /*
    * 乘客长途急件
    * */
    private class VHP {
        TextView titleInfo;
        TextView titleMoney;
        CircleImage icon;
        TextView nickname;
        TextView recentCome;
        TextView myWords;
        TextView hostWords;
        View titleLine;
        TextView startPos;
        TextView endPos;
        TextView transferFee;
        TextView spaceCalled;
        TextView num;
        TextView spaceType;
        TextView baojia;
        TextView departTime;
        LinearLayout ll_owner_info;
        TextView baofei;
        ImageView whoPay;
        TextView text;
        LinearLayout ll_baojia;
        TextView button1;
        TextView button2;
        TextView button3;
    }
    public interface OnOrderHandleListener {
        void onStartService(String order_id,String from,int position);
        void onStartSellTicket(String service_id,String isPermit,String from,int position);
        void onEndSellTicket(String service_id,String isPermit,String from,int position);
        void onCancelOrder(String type,String serviceStatus,String orderId,int position,String from);
        void onCancelAppeal(String orderId,int position,String from);
        void onRouteFinish(String role,String orderId,int position,String from);
        void onAlreadyInCarClick(String orderId,int position,String from);
    }
    public void setOnStartService(OnOrderHandleListener onOrderHandleListener){
        this.onOrderHandleListener = onOrderHandleListener;
    }
}
